import 'dart:io';

import 'main.dart';

extension ExtraFolder on Directory {
  String get name => path.split("/").last;

  List<Directory> get subFolders {
    List<Directory> output = [];
    for (final child in listSync()) {
      if (child is Directory) output.add(child);
    }
    return output;
  }

  List<File> get subFiles {
    List<File> output = [];
    for (final child in listSync()) {
      if (child is File) output.add(child);
    }
    return output;
  }
}

Directory get bitotus {
  Directory folder = Directory(pwd);
  while (folder.name != "bitotus") {
    folder = folder.parent;
    if (folder.parent.path == "/") throw Exception("没有找到bitotus");
  }
  return folder;
}
